function RemoveWinkWalkWeakBuff takes nothing returns nothing
	local timer windWalkWeakBuffTimer = GetExpiredTimer()
	local integer timerId = GetHandleId(windWalkWeakBuffTimer)
	local unit target = LoadUnitHandle(udg_HT , timerId , StringHash("TARGET"))
	//--
	call RemoveSavedHandle(udg_UnitDataHashTable , GetHandleId(target) , StringHash("WIND_WALK_WEAK_BUFF_TIMER"))
	call UnitRemoveAbility(target , 'A01Z')
	call PauseTimer(windWalkWeakBuffTimer)
	call FlushChildHashtable(udg_HT , timerId)
	call DestroyTimer(windWalkWeakBuffTimer)
	//--
endfunction

function AddWindWalkWeakBuff takes nothing returns nothing
	local unit target = GetEnumUnit()
	local integer targetId = GetHandleId(target)
	local timer windWalkWeakBuffTimer = LoadTimerHandle(udg_UnitDataHashTable , targetId , StringHash("WIND_WALK_WEAK_BUFF_TIMER"))
	//--
	if (IsUnitEnemy(target , udg_TempPlayer) and IsUnitInRangeLoc(target , udg_TempCasterLocation , udg_TempRadius) and not IsUnitType(target , UNIT_TYPE_STRUCTURE) and GetUnitState(target , UNIT_STATE_LIFE) > 0.0) then
		call UnitAddAbility(target , 'A01Z')
		if windWalkWeakBuffTimer == null then
			set windWalkWeakBuffTimer = CreateTimer()
		else 
			call PauseTimer(windWalkWeakBuffTimer)
		endif
		call SaveTimerHandle(udg_UnitDataHashTable , targetId , StringHash("WIND_WALK_WEAK_BUFF_TIMER") , windWalkWeakBuffTimer)
		call SaveUnitHandle(udg_HT , GetHandleId(windWalkWeakBuffTimer) , StringHash("TARGET") , target)
		call TimerStart(windWalkWeakBuffTimer , 5.0 , false , function RemoveWinkWalkWeakBuff)
	endif
	//--
endfunction

function WindWalkPickNearUnits takes nothing returns nothing
	local timer pickNearUnitsTimer = GetExpiredTimer()
	local integer timerId = GetHandleId(pickNearUnitsTimer)
	local unit caster = LoadUnitHandle(udg_HT , timerId , StringHash("CASTER"))
	local group nearUnits = CreateGroup()
	//--
	call GroupEnumUnitsInRange(nearUnits , GetUnitX(caster) , GetUnitY(caster) , 100.0 , null)
	set udg_TempPlayer = GetOwningPlayer(caster)
	set udg_TempCasterLocation = GetUnitLoc(caster)
	set udg_TempRadius = 70.0
	call For(nearUnits , function AddWindWalkWeakBuff)
	call RemoveLocation(udg_TempCasterLocation)
endfunction

function WindWalkUnhide takes nothing returns nothing
	local trigger unhideTrigger = GetTriggeringTrigger()
	local triggeraction action = LoadTriggerActionHandle(udg_TriggerDataHashTable , GetHandleId(unhideTrigger) , StringHash("TRIGGER_ACTION"))
	local unit caster = LoadUnitHandle(udg_TriggerDataHashTable , GetHandleId(unhideTrigger) , StringHash("WIND_WALK_CASTER"))
	local timer pickNearUnitsTimer = LoadTimerHandle(udg_UnitDataHashTable , GetHandleId(caster) , StringHash("WIND_WALK_PICK_NEAR_UNITS_TIMER"))
	//--
	call PauseTimer(pickNearUnitsTimer)
	call FlushChildHashtable(udg_HT , GetHandleId(pickNearUnitsTimer))
	call DestroyTimer(pickNearUnitsTimer)
	
	call RemoveSavedHandle(udg_UnitDataHashTable , GetHandleId(caster) , StringHash("WIND_WALK_PICK_NEAR_UNITS_TIMER"))
	
	call FlushChildHashtable(udg_TriggerDataHashTable , GetHandleId(unhideTrigger))
	call TriggerRemoveAction(unhideTrigger , action)
	call DestroyTrigger(unhideTrigger)
	//--
endfunction

function WindWalkAction takes nothing returns nothing
	local trigger unhideTrigger = CreateTrigger()
	local triggeraction action = TriggerAddAction(unhideTrigger , function WindWalkUnhide)
	local timer pickNearUnitsTimer = CreateTimer()
	local integer timerId = GetHandleId(pickNearUnitsTimer)
	local unit caster = GetTriggerUnit()
	local hashtable masteryTable = LoadHashtableHandle(udg_AbilityDataHashTable , 'A01Y' , StringHash("LEVEL_MASTERY_TABLE"))
	local integer abilityLevel = GetUnitAbilityLevel(caster , 'A01Y')
	//--
	call UnitUsedAbilityWithDelta(caster , 'A01Y' , 1.0)
	call SaveUnitHandle(udg_HT , timerId , StringHash("CASTER") , caster)
	call TimerStart(pickNearUnitsTimer , 0.1 , true , function WindWalkPickNearUnits)
	call SaveTimerHandle(udg_UnitDataHashTable , GetHandleId(caster) , StringHash("WIND_WALK_PICK_NEAR_UNITS_TIMER") , pickNearUnitsTimer)
	call TriggerRegisterUnitEvent(unhideTrigger , GetTriggerUnit() , EVENT_UNIT_SPELL_EFFECT)
	call TriggerRegisterTimerEvent(unhideTrigger , LoadReal(masteryTable , abilityLevel , StringHash("DURATION")) , false)
	call SaveTriggerActionHandle(udg_TriggerDataHashTable , GetHandleId(unhideTrigger) , StringHash("TRIGGER_ACTION") , action)
	call SaveUnitHandle(udg_TriggerDataHashTable , GetHandleId(unhideTrigger) , StringHash("WIND_WALK_CASTER") , caster)
	//--
endfunction

function WindWalkTry takes nothing returns nothing
	if GetSpellAbilityId() == 'A01Y' then
		call WindWalkAction()
	endif
endfunction

function InitTrig_WindWalk takes nothing returns nothing
	local hashtable masteryTable = InitHashtable()
	local integer abilityId = 'A01Y'
	//--	
	//call SaveInteger(udg_AbilityDataHashTable , abilityId , StringHash("NEXT_ABILITY") , 'A01X')
	call SaveInteger(udg_AbilityDataHashTable , abilityId , StringHash("HOTKEY") , StringHash("W"))
	call SaveStr(udg_AbilityDataHashTable , abilityId , StringHash("NAME") , "潛行")
	call SaveInteger(udg_AbilityDataHashTable , abilityId , StringHash("MAX_LEVEL") , 3)
	call SaveHashtableHandle(udg_AbilityDataHashTable , abilityId , StringHash("LEVEL_MASTERY_TABLE") , masteryTable)
	call SaveReal(masteryTable , 1 , 0 , 10.0)
	call SaveReal(masteryTable , 2 , 0 , 25.0)
	call SaveReal(masteryTable , 3 , 0 , 50.0)
	
	call SaveReal(masteryTable , 1 , StringHash("DURATION") , 3.0)
	call SaveReal(masteryTable , 2 , StringHash("DURATION") , 4.0)
	call SaveReal(masteryTable , 3 , StringHash("DURATION") , 5.0)
	
	set gg_trg_WindWalk = CreateTrigger()
	call TriggerRegisterPlayerForceUnitEvent(gg_trg_WindWalk , EVENT_PLAYER_UNIT_SPELL_EFFECT)
	call TriggerAddAction(gg_trg_WindWalk , function WindWalkTry)
endfunction